﻿using System;
using System.Collections.Generic;
using System.Text;

using MT.eVotePRS.Service;

namespace MT.eVotePRS.Presentation.Logic
{
    public class ArsProcessSchedule
    {
        private IArsProcessTimer timer;

        public event EventHandler TerminalProcess;

        public ArsProcessSchedule(IArsProcessTimer timer)
        {
            this.timer = timer;
            this.timer.Expired += OnTimerExpired;
        }

        public void Start()
        {
            timer.Start();
        }

        public void Update(TimeSpan duration)
        {
            timer.Duration = duration;
        }

        public void ForceTerminalProcess()
        {
            timer.Stop();
        }

        private void OnTimerExpired(object sender, EventArgs e)
        {
            EventHandler handlers = TerminalProcess;
            if (handlers != null)
            {
                handlers(this, EventArgs.Empty);
            }
        }

    }
}
